var $ = jQuery.noConflict();

$(document).ready(function() {
	//Quantity Plus Logic
   jQuery('.quantity_plus').click(function(){
    var quantity = jQuery(this).parents('.quantity-container').find('.quantity').val();
    quantity = jQuery.trim(quantity);
    
    if (quantity !== '') {
     var numberPattern = /^[0-9]+$/;  
     numberResult = numberPattern.test(quantity);
     if (numberResult === false) {
      alert("Quantity needs to be a valid number");
     } else {
      if (quantity < 0) {
       alert("Quantitye needs to be greater than zero");
      } else {
       var updateQuantity = parseInt(quantity) + 1;
       jQuery(this).parents('.quantity-container').find('.quantity').val(updateQuantity);
      }
     }
    } else {
     alert("Quantity cannot to be null number");
    } 
    return false;
   });
   
   
   //Quantity minus Logic
   jQuery('.quantity_minus').click(function(){
    var quantity = jQuery(this).parents('.quantity-container').find('.quantity').val();
    quantity = jQuery.trim(quantity);
    
    if (quantity !== '') {
     var numberPattern = /^[0-9]+$/;  
     numberResult = numberPattern.test(quantity);
     if (numberResult === false) {
      alert("Quantity needs to be a valid number");
     } else {
      if (quantity <= 1) {
       alert("Quantity needs to be atleast one");
      } else {
       var updateQuantity = parseInt(quantity) - 1;
       jQuery(this).parents('.quantity-container').find('.quantity').val(updateQuantity);
      }
     }
    } else {
     alert("Quantity cannot to be null number");
    } 
    return false;
   });
			
});



